var as = document.querySelectorAll(".banner .i_content .images a");
var lis = document.querySelectorAll(".banner .i_content .images ul li");
var images = document.querySelector(".banner .i_content .images");

var nowIndex = 0;

function changeContent(){
    for(var i = 0;i < as.length;i++){
         as[i].style.display = "none";
    }
    as[nowIndex].style.display = "block";
    
    for(var i = 0;i < lis.length;i++){
         lis[i].className = "normal";
    }
    lis[nowIndex].className = "select";
}

function goLeft(){
    nowIndex -= 1;
    if(nowIndex < 0){
        nowIndex = 4;
    }
    changeContent();
}

function goRight(){
    nowIndex += 1;
    if(nowIndex > 4){
        nowIndex = 0;
    }
    changeContent();
}

for(var i = 0;i < lis.length;i++){
    var li = lis[i];
    li.index = i;
    li.onclick = function(){
        nowIndex = this.index;
        changeContent();
    }
}

function bannerSetInteval(){
    timer = setInterval(function(){
        nowIndex++;
        if(nowIndex > 4){
            nowIndex = 0;
        }
        changeContent();
    },3000)
}

images.onmouseover = function(){
    clearInterval(timer);
}
images.onmouseout = function(){
    bannerSetInteval();
}